package team.common.utility;

import javax.servlet.http.HttpServletRequest;

/**
 * @author  alex
 */
public class ResponseTypeImpl implements ResponseType
{
	/**
	 * @uml.property  name="xmlView"
	 */
	private String xmlView;
	/**
	 * @uml.property  name="jsonView"
	 */
	private String jsonView;
	
	/**
	 * @return
	 * @uml.property  name="xmlView"
	 */
	public String getXmlView() 	{
		return xmlView;
	}
	
	/**
	 * @param xmlView
	 * @uml.property  name="xmlView"
	 */
	public void setXmlView(String xmlView) 	{
		this.xmlView = xmlView;
	}
	
	/**
	 * @return
	 * @uml.property  name="jsonView"
	 */
	public String getJsonView() {
		return jsonView;
	}
	
	/**
	 * @param jsonView
	 * @uml.property  name="jsonView"
	 */
	public void setJsonView(String jsonView) 	{
		this.jsonView = jsonView;
	}
	
	//responseType
	public String getResponseType(HttpServletRequest request) throws Exception
	{	
		String strResponseType = request.getParameter("responseType");
		String strView = null;

		if(strResponseType == "" || strResponseType == null) { //Default
			strResponseType="json";
		}
		
		if(strResponseType.toLowerCase().equals("xml")) {
			strView = this.getXmlView();
		} else 	{
			strView = this.getJsonView();
		}
		
		return strView;
	}

}
